package com.gis.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gis.entity.ProcessData;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface ProcessMapper extends BaseMapper<ProcessData> {

    @Results({
        @Result(column = "id", property = "id"),
        @Result(column = "process_name", property = "processName"),
        @Result(column = "process_description", property = "processDescription"),
        @Result(column = "insert_time", property = "insertTime"),
        @Result(column = "updated_time", property = "updatedTime"),
        @Result(column = "id", property = "nodes", many = @Many(select = "com.gis.mapper.NodeMapper.selectByProcessId"))
    })
    @Select("SELECT * FROM node_table WHERE id = #{id}")
    ProcessData selectProcessById(@Param("id") Long id);

    @Results({
        @Result(column = "id", property = "id"),
        @Result(column = "process_name", property = "processName"),
        @Result(column = "process_description", property = "processDescription"),
        @Result(column = "insert_time", property = "insertTime"),
        @Result(column = "updated_time", property = "updatedTime"),
        @Result(column = "id", property = "nodes", many = @Many(select = "com.gis.mapper.NodeMapper.selectByProcessId"))
    })
    @Select("SELECT * FROM process_table")
    List<ProcessData> selectAllProcessWithNodes();
}
